home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / filefoun.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  2.4 KB  |  79 lines

  1. /*
  2.                             F I L E F O U N . C
  3.  
  4.     With the MS-DOS implementation the received attribute is compared
  5.     to the request:
  6.  
  7.     O_FILE:     accepts only A_NORMAL, A_ARCH/A_READ with A_NORMAL accepted
  8.     O_DIR:      accepts only A_SUBDIR
  9.     O_SUBDIR:   accepts only A_SUBDIR, but not the . and ..
  10.     O_ALL:      accepts all
  11.  
  12.     Not yet supported: O_VOLID:    accepts A_VOLID
  13.  
  14. */
  15.  
  16. #include "icrssdef.h"
  17.  
  18. char *filefound()
  19. {
  20.     register unsigned
  21.         request,
  22.         received;
  23.  
  24.     received = ifs.find.attrib;             /* use fast registers */
  25.     request = ifs.attrib;
  26.  
  27.     /* First part: see if request */
  28.     /* matches attribute of entry */
  29.  
  30.     if                                      /* (list all accepted variants) */
  31.     (
  32.         !                                   /* if not: */
  33.         (
  34.             (
  35.              (request & O_FILE)             /* FILE requested, and */
  36.              &&                             /* an attribute received  */
  37.              !                              /* indicating that it's no file */
  38.              (
  39.                  received &
  40.                  (A_SUBDIR | A_HIDDEN | A_SYSTEM | A_VOLID)
  41.              )
  42.             )
  43.             ||
  44.             (
  45.              (request & (O_SUBDIR | O_DIR)) /* OR: any subdir requested */
  46.              &&                             /* and A_SUBDIR received */
  47.              (received & A_SUBDIR)
  48.             )
  49.             ||
  50.             (
  51.              (request & O_ALL)              /* OR: ALL requested */
  52.              &&                             /* and not volume label received */
  53.              !(received & A_VOLID)
  54.             )
  55.         )
  56.     )
  57.         return (NULL);                      /* then reject the entry */
  58.  
  59.  
  60.     /* Second part: O_SUBDIR (overruled by O_ALL / O_DIR)   */
  61.     /*              entries '.' and '..' are rejected       */
  62.  
  63.     if
  64.     (
  65.         !(request & (O_DIR | O_ALL))        /* not O_DIR / O_ALL requested, */
  66.         &&                                  /* AND */
  67.         (request & O_SUBDIR)                /* clean subdir requested */
  68.         &&                                  /* AND */
  69.         (
  70.             !strcmp(ifs.find.name, ".")     /* . or .. found */
  71.             ||
  72.             !strcmp(ifs.find.name, "..")
  73.         )
  74.     )
  75.         return (NULL);                      /* then reject the entry */
  76.  
  77.     return (ifs.find.name);                 /* return found name */
  78. }
  79.